package com.itheima.service.Impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.mapper.MemberMapper;
import com.itheima.pojo.LoginDto;
import com.itheima.pojo.Member;
import com.itheima.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MemberServiceImpl implements MemberService {
    @Autowired
    private MemberMapper memberMapper;
    @Override
    public Member seletMember(LoginDto loginDto) {
        LambdaQueryWrapper<Member> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(Member::getPhoneNumber,loginDto.getTelephone());
        Member member = memberMapper.selectOne(wrapper);
        return member;
    }

    @Override
    public void addMember(LoginDto loginDto) {
        Member member=new Member();
        member.setPhoneNumber(loginDto.getTelephone());
        memberMapper.insert(member);
    }
}
